//
//  YLStringExtension.swift
//  iosh5vue
//
//  Created by lyl on 2021/3/1.
//  Copyright © 2021 lyl. All rights reserved.
//

import Foundation
extension String {
    func toDictionary() -> [String:Any]? {
        guard let jsonData:Data = self.data(using: .utf8) else {
            print("json转dict失败")
            return nil
        }
        if let dict = try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers) {
            return dict as? [String : Any] ?? ["":""]
        }
        print("json转dict失败")
        return nil
    }
}
